home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / tools / textcolors.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  3KB  |  102 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    textcolors - 
  19.  *        Set the color indexes used for the textport.
  20.  *
  21.  *                Paul Haeberli - 1985
  22.  */
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include "gl.h"
  26.  
  27. static char* termtype;
  28. int is_3k(), is_4d();
  29. extern char *getenv();
  30.  
  31. main(argc,argv)
  32. int argc;
  33. char **argv;
  34. {
  35.     int i;
  36.     int args[10];
  37.  
  38.     if ((argc == 5) || (argc == 7)) {
  39.     for (i=1;i<=argc-1;i++) {
  40.         if (sscanf(argv[i],"%ld",&args[i])!=1)
  41.         goto error;
  42.     }
  43.     if (is_3k()) {
  44.         printf("\0337F%c",'0'+args[1]);
  45.         printf("\0337B%c",'0'+args[2]);
  46.         printf("\0337R%c",'0'+args[3]);
  47.         printf("\0337C%c",'0'+args[4]);
  48.     } else if (is_4d()) {
  49.         printf("\033[101;%d/y",args[1]);
  50.         printf("\033[102;%d/y",args[2]);
  51.         printf("\033[103;%d/y",args[3]);
  52.         printf("\033[104;%d/y",args[4]);
  53.         if (argc == 7)
  54.         printf("\033[111;%d;%d/y", args[5], args[6]);
  55.     }
  56.     exit(0);
  57.     }
  58.  
  59. error:
  60.     fprintf(stderr, "usage: textcolors text page reverse cursor");
  61.     if (is_4d())
  62.     fprintf(stderr, " {selfg selbg}");
  63.     fprintf(stderr, "\n");
  64.     exit(1);
  65. }
  66.  
  67.  
  68. /*
  69.  * termcap type textport support
  70.  *     is_3k(), is_4d() test TERM variable for
  71.  *
  72.  * if the TERM variable contains "iris", but is not prefixed 
  73.  * by "iris-" the terminal is judged to be a IRIS3XXX terminal emulator
  74.  */
  75. int is_3k()
  76. {
  77.    int i;
  78.  
  79.    termtype = getenv("TERM");
  80.    if (!termtype) 
  81.        return FALSE;
  82.    if (!strncmp( termtype, "iris-", 5 )) 
  83.        return FALSE;
  84.    for (i=1;i<strlen(termtype); i++) {
  85.        if (*(termtype+i)=='i') {
  86.        if (!strncmp( (termtype+i), "iris", 4)) 
  87.            return TRUE;
  88.        }
  89.    }
  90.    return FALSE;
  91. }
  92.  
  93. int is_4d() 
  94. {
  95.    termtype = getenv("TERM");
  96.    if (!termtype) 
  97.        return FALSE;
  98.    if (!strncmp( termtype, "iris-", 5 )) 
  99.        return TRUE;
  100.    return FALSE;
  101. }
  102.